from django.db import models

# Create your models here.


class Category(models.Model):
    title = models.CharField(verbose_name="版本名", max_length=20, unique=True)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "版本"
        verbose_name_plural = "版本"


class Label(models.Model):
    title = models.CharField(verbose_name="标签名", max_length=20, unique=True)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "标签"
        verbose_name_plural = "标签"


class Status(models.Model):
    title = models.CharField(verbose_name="状态名", max_length=20, unique=True)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "状态"
        verbose_name_plural = "状态"


class Anime(models.Model):
    title = models.CharField(verbose_name="番名", max_length=30, unique=True)
    image = models.ImageField(verbose_name="图片", upload_to='image', blank=True, null=True)
    imglink = models.CharField(verbose_name="图片名字", max_length=30, unique=True, default='null')
    agelink = models.CharField(verbose_name="age名字", max_length=30,  default='null')
    introduce = models.CharField(verbose_name="简介", max_length=500, default="")
    views = models.CharField(verbose_name="浏览量", max_length=30, default=0)
    episode = models.IntegerField(verbose_name="集数",  default=0)
    pub_date = models.DateField(verbose_name="首播时间", blank=True, null=True)
    category = models.ForeignKey(Category, verbose_name="版本名",on_delete=models.CASCADE)
    label = models.ManyToManyField(verbose_name="标签", to="Label")
    author = models.CharField(verbose_name="作者", max_length=30)
    status = models.ForeignKey(Status, verbose_name="状态", on_delete=models.CASCADE)
    link = models.CharField(verbose_name="官方网站", max_length=100)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = "番剧"
        verbose_name_plural = "番剧"